pub fn min_edge_prime_num(ratio: u32) -> String {
    fn mod_mul(a: u64, b: u64, n: u64) -> u64 {
        ((a as u128 * b as u128) % n as u128) as u64
    }

    fn mod_pow(mut base: u64, mut exp: u64, modulus: u64) -> u64 {
        if modulus == 1 {
            return 0;
        }
        let mut result = 1;
        base %= modulus;
        while exp > 0 {
            if exp & 1 == 1 {
                result = mod_mul(result, base, modulus);
            }
            base = mod_mul(base, base, modulus);
            exp >>= 1;
        }
        result
    }

    fn is_prime(n: u64) -> bool {
        if n <= 1 {
            return false;
        }
        if n <= 3 {
            return true;
        }
        if n % 2 == 0 || n % 3 == 0 {
            return false;
        }

        let special_primes = [2, 3, 5, 13, 19, 73, 193, 407521, 299210837];
        for &p in &special_primes {
            if n == p {
                return true;
            }
            if n % p == 0 {
                return false;
            }
        }

        if n < 1_000_000 {
            let sqrt = (n as f64).sqrt() as u64;
            let mut i = 5;
            while i <= sqrt {
                if n % i == 0 || n % (i + 2) == 0 {
                    return false;
                }
                i += 6;
            }
            return true;
        }

        // Deterministic Miller-Rabin
        let bases = [2, 325, 9375, 28178, 450775, 9780504, 1795265022];
        let mut d = n - 1;
        let mut r = 0;
        while d % 2 == 0 {
            d /= 2;
            r += 1;
        }

        'next_base: for &a in bases.iter().take_while(|&&x| x < n) {
            let mut x = mod_pow(a, d, n);
            if x == 1 || x == n - 1 {
                continue;
            }

            for _ in 0..r - 1 {
                x = mod_mul(x, x, n);
                if x == n - 1 {
                    continue 'next_base;
                }
            }
            return false;
        }
        true
    }

    let mut edge = 1;
    let mut total_diagonals = 1;
    let mut total_primes = 0;

    loop {
        edge += 2;
        let n = edge as u64;
        let k = n - 1;
        let n2 = n * n;

        for i in 1..=3 {
            let num = n2 - i * k;
            if is_prime(num) {
                total_primes += 1;
            }
        }

        total_diagonals += 4;

        if (total_primes * 100) < (total_diagonals * ratio as usize) {
            return format!("{},{}", edge, total_primes);
        }
    }
}
